package com.example.springboot.mapper;

import com.example.springboot.bean.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/10/9 20:53
 */
@Mapper
public interface DepartmentMapper {
    /**
     * 根据id查找
     * @param id
     * @return
     */
    @Select("select * from department where id=#{id}")
    Department getById(Integer id);

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @Delete("delete from department where id=#{id}")
    int deleteDeptById(Integer id);

    /**
     * 插入
     * @param department
     * @return
     */
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into department(departmentName) values(#{departmentName})")
    int insertDept(Department department);

    /**
     * 更新
     * @param department
     * @return
     */
    @Update("update department set departmentName=#{departmentName} where id=#{id}")
    int updateDept(Department department);
    @Select("select * from department where id in #{ids}")
    List<Department> findByIds(List<Integer> ids);
}
